package com.aidex.web.controller.api;

import com.aidex.biz.domain.*;
import com.aidex.biz.service.*;
import com.aidex.common.core.controller.BaseController;
import com.aidex.common.core.domain.R;
import com.aidex.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 驾驶舱 专项接口
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2022-04-22
 */
@RestController("ApiInfoController")
@RequestMapping("/webApi/jsc")
public class IndexController extends BaseController {

    @Autowired
    private ZhuanxiangAssessService zhuanxiangAssessService;
    @Autowired
    private ZhongdianProjectService zhongdianProjectService;
    @Autowired
    private BizAnhuanZicanListService bizAnhuanZicanListService;

    @Autowired
    private AnHuanProjectApiService anHuanProjectApiServie;
    @Autowired
    private BizZjwzInfoService bizZjwzInfoService;
    @Autowired
    private BizRcjdInfoService bizRcjdInfoService;

    @GetMapping("/zhuanxiangtypelist")
    public R zhuanxiangtypelist(ZhuanxiangAssess zhuanxiangAssess) {
        return R.data(zhuanxiangAssessService.getZhuanxiangAssessMap(zhuanxiangAssess));
    }

    @GetMapping("/zhuanxianglist")
    public R zhuanxianglist(ZhuanxiangAssess zhuanxiangAssess) {
        return R.data(zhuanxiangAssessService.findList(zhuanxiangAssess));
    }

    @GetMapping("/zhongdianProject")
    public R zhongdianProject() {
        return R.data(zhongdianProjectService.findList(new ZhongdianProject()));
    }

    @GetMapping("/anhuanProject")
    public R anhuanProject() {
        return R.data(bizAnhuanZicanListService.findList(new BizAnhuanZicanList()));
    }

    @GetMapping("/getAnhuanProjectDetails")
    public R getAnhuanProjectDetails(BizAnhuanZicanList bizAnhuanZicanList) {
        return R.data(anHuanProjectApiServie.getZiChanDetail(bizAnhuanZicanList.getId()));
    }

    @GetMapping("/getRcjd")
    public R getRcjd() {
        return R.data(bizRcjdInfoService.findList(new BizRcjdInfo()));
    }

    @GetMapping("/getZjwz")
    public R getZjwz(BizZjwzInfo bizZjwzInfo) {
        if (!StringUtils.isNotNull(bizZjwzInfo.getParamTimes())) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            bizZjwzInfo.setParamTimes(new Date());
        }
        return R.data(bizZjwzInfoService.getListByTimes(bizZjwzInfo));
    }


}
